package interfaces2;

public class Point2D_dist<T extends Number> extends Point2D<T> implements DistanceMeasurable<T>, Comparable< Point2D<T> > {
	/**
	 * Data Members
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * Methods
	 */
	public Point2D_dist(T x_in, T y_in) {
		super(x_in, y_in);
	}

	public Number distance() {
		double x2 = getX().doubleValue();
		x2 = x2*x2;
		double y2 = getY().doubleValue();
		y2 = y2*y2;
		double result = Math.sqrt( x2 + y2 );
		Double dr = result;
		return dr;
	}

	public int compareTo(Point2D<T> o) {
		return toString().compareTo( o.toString() );
	}
}
